
#include <PluginLib/Export>
#include "PluginLib/OcDyPublic.h"
//-----------------------------------------------------------------------
DynLib::DynLib( const String& name )
{
  mName = name;
  m_hInst = NULL;
}

//-----------------------------------------------------------------------
DynLib::~DynLib()
{
}

//-----------------------------------------------------------------------
void DynLib::load()
{
  // Log library load


 String name = mName;


  m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str());

  if( !m_hInst )
  {
    DWORD dwError = ::GetLastError();
#ifdef _DEBUG
    {

    }

#endif // _DEBUG
 
  }
}

//-----------------------------------------------------------------------
void DynLib::unload()
{


  if( DYNLIB_UNLOAD( m_hInst ) )
  {
	  int isLoad = false;
   
  }

}

//-----------------------------------------------------------------------
void* DynLib::getSymbol( const String& strName ) const throw()
{
  return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
}
//-----------------------------------------------------------------------
String DynLib::dynlibError( void ) 
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
  LPVOID lpMsgBuf; 
  FormatMessage( 
    FORMAT_MESSAGE_ALLOCATE_BUFFER | 
    FORMAT_MESSAGE_FROM_SYSTEM | 
    FORMAT_MESSAGE_IGNORE_INSERTS, 
    NULL, 
    GetLastError(), 
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
    (LPTSTR) &lpMsgBuf, 
    0, 
    NULL 
    ); 
  String ret = (char*)lpMsgBuf;
  // Free the buffer.
  LocalFree( lpMsgBuf );
  return ret;
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
  return String(dlerror());
#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
  return String(mac_errorBundle());
#else
  return String("");
#endif
}
